package cn.edu.nhic.order;

import androidx.appcompat.app.AppCompatActivity;

import android.content.Intent;
import android.os.Bundle;
import android.widget.ImageView;
import android.widget.ListView;

import java.math.BigDecimal;
import java.util.ArrayList;
import java.util.List;

import cn.edu.nhic.order.adapter.ShopDetailAdapter;
import cn.edu.nhic.order.bean.FoodBean;
import cn.edu.nhic.order.bean.ShopBean;

/**
 * 店铺详情页
 */
public class ShopDetailActivity extends AppCompatActivity {
    private ListView shopDetailListView;
    private List<FoodBean> foodBeanList;
    private Intent intent;
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_shop_detail);
        intent=getIntent();
        //1.初始化视图
        this.initView();
        //2.初始化数据
        this.initData1();
        //3.初始化适配器
        this.initAdapter();
        //4.初始化事件
        this.initEvent();
    }

    //1.初始化视图
    public void initView(){
        this.shopDetailListView=this.findViewById(R.id.shop_detail_listView);
    }
    //2.初始化数据
    public void initData1(){
        ShopBean shopBean= (ShopBean) intent.getSerializableExtra("shopBean");
        this.foodBeanList=shopBean.getFoodList();
    }
    //2.初始化数据
    public void initData(){
        this.foodBeanList=new ArrayList<FoodBean>();
        FoodBean fb1=new FoodBean();
        fb1.setFoodName("珍珠奶茶");
        fb1.setPopularity("门店排名第1名");
        fb1.setSaleNum("月售336");
        fb1.setPopularity("好评度100%");
        fb1.setPrice(new BigDecimal(14));
        this.foodBeanList.add(fb1);
        FoodBean fb2=new FoodBean();
        fb2.setFoodName("大满贯布丁奶茶");
        fb2.setPopularity("门店排名第1名");
        fb2.setSaleNum("月售336");
        fb2.setPopularity("好评度100%");
        fb2.setPrice(new BigDecimal(14));
        this.foodBeanList.add(fb2);
        FoodBean fb3=new FoodBean();
        fb3.setFoodName("网红蛋糕奶茶");
        fb3.setPopularity("门店排名第1名");
        fb3.setSaleNum("月售336");
        fb3.setPopularity("好评度100%");
        fb3.setPrice(new BigDecimal(14));
        this.foodBeanList.add(fb3);


    }

    //3.初始化适配器
    public void initAdapter(){
        ShopDetailAdapter shopDetailAdapter=new ShopDetailAdapter(this,R.layout.food_item,this.foodBeanList);
        this.shopDetailListView.setAdapter(shopDetailAdapter);
    }

    //4.初始化事件
    public void initEvent(){

    }
}